home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-25 | 27.0 KB | 966 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: BaseShp.cpp
- // Release Version: $ ODF 1 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "ODFDraw.hpp"
-
- #ifndef BASESHP_H
- #include "BaseShp.h"
- #endif
-
- #ifndef UTILS_H
- #include "Utils.h"
- #endif
-
- #ifndef CONSTANT_H
- #include "Constant.h"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k"
- #endif
-
- #ifndef DRAWCONT_H
- #include "DrawCont.h"
- #endif
-
- #ifndef DRAWPART_H
- #include "DrawPart.h"
- #endif
-
- #ifndef DRAWPART_H
- #include "DrawPart.h"
- #endif
-
- #ifndef DRAWFRM_H
- #include "DrawFrm.h"
- #endif
-
- #ifndef DRAWPRXY_H
- #include "DrawPrxy.h"
- #endif
-
- #ifndef DRAWLINK_H
- #include "DrawLink.h"
- #endif
-
- #ifndef DRAWCLIP_H
- #include "DrawClip.h"
- #endif
-
- // ----- Part Layer -----
-
- #ifndef FWAPLEVT_H
- #include "FWAplEvt.h"
- #endif
-
- #ifndef FWFRMING_H
- #include "FWFrming.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWINTER_H
- #include "FWInter.h"
- #endif
-
- #ifndef FWPRMISE_H
- #include "FWPrmise.h"
- #endif
-
- #ifndef FWDSCOPR_H
- #include "FWDscOpr.h"
- #endif
-
- #ifndef FWSEMTRM_H
- #include "FWSemTrm.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWACQUIR_H
- #include "FWAcquir.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWTXTBOX_H
- #include "FWTxtBox.h"
- #endif
-
- #ifndef FWLINSHP_H
- #include "FWLinShp.h"
- #endif
-
- #ifndef FWOVLSHP_H
- #include "FWOvlShp.h"
- #endif
-
- #ifndef FWRRCSHP_H
- #include "FWRRcShp.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- //========================================================================================
- // Runtime Information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfdrawshapes
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- FW_DEFINE_AUTO(CBaseShape)
- FW_DEFINE_CLASS_M1(CBaseShape, FW_MScriptable)
-
- const FW_ClassTypeConstant LBaseShape = FW_TYPE_CONSTANT('s','h','b','a');
- FW_REGISTER_ARCHIVABLE_CLASS(LBaseShape, CBaseShape, CBaseShape::Read, 0, 0, CBaseShape::Write)
-
- //========================================================================================
- // globals
- //========================================================================================
-
- FW_CRectShape* CBaseShape::gWorkingHandle = NULL;
- unsigned long CBaseShape::gShapeCount = 0;
-
- // [KVV] Constructing gDefaultStyle and gDefaultInk like this causes
- // problems because of order of initialization
- // const FW_CStyle gDefaultStyle = FW_kNormalStyle;
- // const FW_CInk gDefaultInk = FW_kNormalInk;
-
- const FW_EStandardStyles gDefaultStyle = FW_kNormalStyle;
- const FW_EStandardInks gDefaultInk = FW_kNormalInk;
-
- //========================================================================================
- // class CShapeCollection
- //========================================================================================
-
- FW_DEFINE_AUTO(CShapeCollection)
-
- //========================================================================================
- // class CShapeCollectionIterator
- //========================================================================================
-
- FW_DEFINE_AUTO(CShapeCollectionIterator)
-
- //========================================================================================
- // class CBaseShape
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::CBaseShape
- //----------------------------------------------------------------------------------------
-
- CBaseShape::CBaseShape(short numberOfHandles,
- unsigned short shapeType,
- unsigned short renderVerb) :
- FW_MScriptable(),
- fSelected(FALSE),
- fNumberOfHandles(numberOfHandles),
- fShapeType(shapeType),
- fPublishLink(NULL),
- fSubscribeLink(NULL),
- fRenderVerb(renderVerb),
- fFrameInk(gDefaultInk),
- fFillInk(gDefaultInk),
- fFrameStyle(gDefaultStyle),
- fFillStyle(gDefaultStyle),
- fPromised(0),
- fExternalizationIndex(0)
- {
- InitStatic();
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::CBaseShape
- //----------------------------------------------------------------------------------------
-
- CBaseShape::CBaseShape(FW_CReadableStream& archive) :
- FW_MScriptable(),
- fPublishLink(NULL),
- fSubscribeLink(NULL),
- fSelected(FALSE),
- fPromised(0),
- fExternalizationIndex(0)
- {
- InitStatic();
-
- archive >> fShapeType;
- archive >> fNumberOfHandles;
-
- archive >> fFrameInk;
- archive >> fFillInk;
- archive >> fFrameStyle;
- archive >> fFillStyle;
-
- archive >> fRenderVerb;
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::InitStatic
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::InitStatic()
- {
- if (gShapeCount == 0)
- {
- CBaseShape::gWorkingHandle = FW_NEW(FW_CRectShape, (FW_kZeroRect, FW_kFill));
- CBaseShape::gWorkingHandle->SetInk(FW_kInvertInk);
- }
-
- CBaseShape::gShapeCount++;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::~CBaseShape
- //----------------------------------------------------------------------------------------
-
- CBaseShape::~CBaseShape()
- {
- FW_START_DESTRUCTOR
- FW_ASSERT(fPromised == 0); // I should have resolved all my promises
-
- CBaseShape::gShapeCount--;
- if (CBaseShape::gShapeCount == 0)
- delete CBaseShape::gWorkingHandle;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::Removed
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::Removed(Environment* ev)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::Deleted
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::Deleted(Environment* ev)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::CheckPromise
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::CheckPromise(Environment* ev, FW_CPart* part)
- {
- if (fPromised & FW_kLinkStorage)
- {
- // I don't want to call FW_CDataInterchange::ResolveAllPromises for link promises
- // because I only want to resolve link promises involving this shape.
- FW_ASSERT(fPublishLink != NULL && fPublishLink->IsPromised(ev));
- fPublishLink->ResolveAllPromises(ev);
- }
- FW_ASSERT((fPromised & FW_kLinkStorage) == 0); // because CBaseShape::Promised should have been called
-
- if (fPromised & FW_kClipboardStorage)
- part->GetDataInterchange(ev)->ResolveClipboardPromise(ev);
- FW_ASSERT((fPromised & FW_kClipboardStorage) == 0); // because CBaseShape::Promised should have been called
-
- FW_ASSERT(fPromised == 0);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::Promised
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::Promised(FW_EStorageKinds storageKind, FW_Boolean state)
- {
- if (state)
- fPromised |= storageKind;
- else
- fPromised ^= fPromised & storageKind;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::TrackFeedback
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::TrackFeedback(Environment* ev,
- ODFacet* facet,
- FW_CGraphicContext& gc,
- const FW_CPoint& anchorPoint,
- const FW_CPoint& currentPoint,
- FW_Boolean erase)
- {
- if (!erase)
- SetShapeGeometry(anchorPoint, currentPoint);
-
- RenderShape(ev, facet, gc);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::SelectShape
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::SelectShape(Environment* ev, FW_Boolean state)
- {
- fSelected = state;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::ClearCache
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::ClearCache()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::RenderHandles
- //----------------------------------------------------------------------------------------
- // if asynchFacet is != NULL it means we are drawing asynchronously in a facet
-
- void CBaseShape::RenderHandles(FW_CGraphicContext& gc)
- {
- FW_CPoint penSize = gc.DeviceToLogical(2, 2);
- for (short i=1; i<=fNumberOfHandles; i++)
- {
- CalcHandle(i, CBaseShape::gWorkingHandle, penSize);
- CBaseShape::gWorkingHandle->Render(gc);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::CalcHandle
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::CalcHandle(short whichHandle, FW_CRectShape* handle, const FW_CPoint& penSize) const
- {
- FW_CPoint pt;
- GetHandleCenter(whichHandle, pt);
-
- FW_Fixed fx = penSize.x + FW_ODFixedToFixed(0x00008000);
- FW_Fixed fy = penSize.y + FW_ODFixedToFixed(0x00008000);
- // const FW_Fixed fx25 = FW_DoubleToFixed(2.5);
- FW_CRect rect(pt.x - fx, pt.y - fy, pt.x + fx, pt.y + fy);
-
- handle->SetRectangle(rect);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::InSelectionRect
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CBaseShape::InSelectionRect(const FW_CRect& selectRect) const
- {
- FW_CRect bounds = GetRectGeometry();
-
- FW_CRect temp(bounds);
- temp.Intersection(selectRect);
-
- return bounds == temp;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::Flatten
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::Flatten(FW_CWritableStream& archive)
- {
- archive << fShapeType;
- archive << fNumberOfHandles;
-
- archive << fFrameInk;
- archive << fFillInk;
- archive << fFrameStyle;
- archive << fFillStyle;
-
- archive << fRenderVerb;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::MovedAfter
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::MovedAfter(Environment* ev, CBaseShape* shape)
- {
- FW_UNUSED(shape);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::MovedBefore
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::MovedBefore(Environment* ev, CBaseShape* shape)
- {
- FW_UNUSED(shape);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::MovedFirst
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::MovedFirst(Environment* ev)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::MovedLast
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::MovedLast(Environment* ev)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::RestoreShape
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::RestoreShape(Environment *ev, CDrawPart* drawPart)
- {
- drawPart->AddShapeToPart(ev, this);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::SetFrozen
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CBaseShape::SetFrozen(FW_Boolean state)
- {
- FW_UNUSED(state);
- return FALSE; // Means I don't care
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::IsFrozen
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CBaseShape::IsFrozen() const
- {
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetPenSize
- //----------------------------------------------------------------------------------------
-
- FW_Fixed CBaseShape::GetPenSize() const
- {
- return HasFrameStyle() ? fFrameStyle.GetPenSize() : FW_kFixed0;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetColor
- //----------------------------------------------------------------------------------------
- void CBaseShape::GetColor(FW_Boolean fill, FW_CColor& color)
- {
- if (fill)
- fFillInk.GetForeColor(color);
- else
- fFrameInk.GetForeColor(color);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetPattern
- //----------------------------------------------------------------------------------------
- FW_CPattern CBaseShape::GetPattern(FW_Boolean fill)
- {
- if (fill)
- return fFillStyle.GetPattern();
- else
- return fFrameStyle.GetPattern();
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::UnshareInk
- //----------------------------------------------------------------------------------------
-
- FW_CInk CBaseShape::UnshareInk(const FW_CInk& ink) const
- {
- // Do not use the following syntax. It looks like the life time of temporaries
- // is wrong causing a bad refcounting problem
- // return (ink->GetRefCount() > 1) ? ink->Copy() : ink;
-
- if (ink.GetRefCount() > 1)
- return ink.Copy();
- else
- return ink;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::UnshareStyle
- //----------------------------------------------------------------------------------------
-
- FW_CStyle CBaseShape::UnshareStyle(const FW_CStyle& style) const
- {
- // Do not use the following syntax. It looks like the life time of temporaries
- // is wrong causing a bad refcounting problem
- // return (style->GetRefCount() > 1) ? style->Copy() : style;
-
- if (style.GetRefCount() > 1)
- return style.Copy();
- else
- return style;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::ChangeFrameColor
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::ChangeFrameColor(Environment* ev, CDrawPart* part, const FW_CColor& color)
- {
- if (HasFrameStyle())
- {
- CheckPromise(ev, part);
-
- fFrameInk = UnshareInk(fFrameInk);
- fFrameInk.SetForeColor(color);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::ChangeFramePattern
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::ChangeFramePattern(Environment* ev, CDrawPart* part, const FW_CPattern& pattern)
- {
- if (HasFrameStyle())
- {
- CheckPromise(ev, part);
-
- fFrameStyle = UnshareStyle(fFrameStyle);
- fFrameStyle.SetPattern(pattern);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::ChangeFillColor
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::ChangeFillColor(Environment* ev, CDrawPart* part, const FW_CColor& color)
- {
- if (HasFillStyle())
- {
- CheckPromise(ev, part);
-
- fFillInk = UnshareInk(fFillInk);
- fFillInk.SetForeColor(color);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::ChangeFillPattern
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::ChangeFillPattern(Environment* ev, CDrawPart* part, const FW_CPattern& pattern)
- {
- if (HasFillStyle())
- {
- CheckPromise(ev, part);
-
- fFillStyle = UnshareStyle(fFillStyle);
- fFillStyle.SetPattern(pattern);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::ChangePenSize
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::ChangePenSize(Environment* ev, CDrawPart* part, FW_Fixed newPenSize)
- {
- if (HasFrameStyle())
- {
- CheckPromise(ev, part);
-
- ClearCache();
-
- fFrameStyle = UnshareStyle(fFrameStyle);
- fFrameStyle.SetPenSize(newPenSize);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::SetSubscribeLink
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::SetSubscribeLink(Environment* ev, CDrawSubscribeLink *subscribeLink)
- {
- FW_UNUSED(ev);
-
- fSubscribeLink = subscribeLink;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::SetPublishLink
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::SetPublishLink(Environment* ev, CDrawPublishLink *publishLink)
- {
- FW_UNUSED(ev);
-
- fPublishLink = publishLink;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::AdjustRectForPenSize
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::AdjustRectForPenSize(FW_CRect& rect, FW_Fixed penSize) const
- {
- FW_Fixed half = FW_Half(penSize);
- rect.Inset(-half, -half);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::ChangeRenderVerb
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::ChangeRenderVerb(Environment* ev, CDrawPart* part, unsigned short renderVerb)
- {
- CheckPromise(ev, part);
-
- ClearCache();
- fRenderVerb = renderVerb;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetObjectClass
- //----------------------------------------------------------------------------------------
-
- ODDescType CBaseShape::GetObjectClass() const
- {
- return kShapeClass;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::HasProperty
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CBaseShape::HasProperty(ODDescType whichProperty) const
- {
- FW_Boolean hasProperty;
-
- switch (whichProperty)
- {
- case kShapeTypeProperty:
- case pColor:
- case pPosition:
- case pBounds:
- case pIndex:
- hasProperty = TRUE;
- break;
-
- default:
- hasProperty = FW_MScriptable::HasProperty(whichProperty);
- break;
- }
- return hasProperty;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetProperty
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CBaseShape::GetProperty(Environment* ev,
- FW_CPart* part,
- FW_CDesc& propertyValue,
- ODDescType whichProperty,
- ODDescType desiredType) const
- {
- FW_Boolean result = TRUE;
-
- switch (whichProperty)
- {
- case kShapeTypeProperty:
- {
- ODDescType shapeType;
- switch (GetShapeType())
- {
- case kLineShape:
- shapeType = kLineShapeType;
- break;
-
- case kRectShape:
- shapeType = kRectShapeType;
- break;
-
- case kOvalShape:
- shapeType = kOvalShapeType;
- break;
-
- case kRRectShape:
- shapeType = kRRectShapeType;
- break;
-
- case kTextShapeType:
- shapeType = kTextShapeType;
- break;
-
- default:
- FW_THROW(FW_XException(errAEEventNotHandled));
- break;
- }
- propertyValue.PutEnumeratedType(shapeType);
- }
- break;
-
- case pColor:
- {
- FW_CColor color = fFillInk.GetForeColor();
- propertyValue << color;
- }
- break;
-
- case pPosition:
- propertyValue << GetRectGeometry().TopLeft().AsPlatformPoint();
- break;
-
- case pBounds:
- // propertyValue << GetRectGeometry();
- break;
-
- default:
- result = FW_MScriptable::GetProperty(ev, part, propertyValue, whichProperty, desiredType);
- break;
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::SetProperty
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::SetProperty(Environment* ev,
- FW_CPart* part,
- FW_CDesc& propertyValue,
- ODDescType whichProperty)
- {
- switch (whichProperty)
- {
- case pColor:
- {
- CDrawPart* drawPart = FW_DYNAMIC_CAST(CDrawPart, part);
- if (drawPart && HasFillStyle())
- {
- FW_CColor newColor;
- propertyValue >> newColor;
-
- FW_CColor oldColor;
- GetColor(TRUE, oldColor);
-
- if (newColor != oldColor)
- {
- ChangeFillColor(ev, drawPart, newColor);
- drawPart->GetDrawContent()->RedrawShape(ev, this);
- }
- }
- }
- break;
-
- case pPosition:
- {
- CDrawPart* drawPart = FW_DYNAMIC_CAST(CDrawPart, part);
-
- if (drawPart)
- {
- FW_SPlatformPoint newPlatformPosition;
- FW_CRect bounds = GetRectGeometry();
-
- propertyValue >> newPlatformPosition;
-
- FW_CPoint newPosition(newPlatformPosition);
-
- drawPart->GetDrawContent()->RedrawShape(ev, this); // inval the old location
- OffsetShape(ev, newPosition.x - bounds.left, newPosition.y - bounds.top);
- drawPart->GetDrawContent()->RedrawShape(ev, this); // inval the new location
- }
- }
- break;
-
- default:
- FW_MScriptable::SetProperty(ev, part, propertyValue, whichProperty);
- break;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetUndoStrings
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::GetUndoStrings(Environment* ev,
- FW_CPart* part,
- ODDescType whichProperty,
- FW_CString& undoString,
- FW_CString& redoString) const
- {
- if (whichProperty == pColor)
- {
- FW_CSharedLibraryResourceFile resFile(ev);
- ::FW_LoadStringByID(ev, resFile, kDrawUndoStrings, MULTISTRINGRES, kUndoFillColorMsg, undoString);
- ::FW_LoadStringByID(ev, resFile, kDrawUndoStrings, MULTISTRINGRES, kRedoFillColorMsg, redoString);
- }
- else
- FW_MScriptable::GetUndoStrings(ev, part, whichProperty, undoString, redoString);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::Read
- //----------------------------------------------------------------------------------------
-
- void* CBaseShape::Read(FW_CReadableStream& stream, FW_ClassTypeConstant type)
- {
- FW_UNUSED(stream);
- FW_UNUSED(type);
- FW_DEBUG_MESSAGE("CBaseShape::Read should never be called");
- return NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::Write
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::Write(FW_CWritableStream& stream, FW_ClassTypeConstant type, const void *object)
- {
- FW_UNUSED(type);
- ((CBaseShape*)object)->Flatten(stream);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetUpdateBox
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::GetUpdateBox(Environment* ev, ODShape* updateBox) const
- {
- FW_CRect bounds = GetRectGeometry();
-
- const FW_Fixed fxMargin = FW_IntToFixed(3);
-
- bounds.left -= fxMargin;
- bounds.top -= fxMargin;
- bounds.right += fxMargin;
- bounds.bottom += fxMargin;
-
- ODRect odBounds = bounds;
- updateBox->SetRectangle(ev, &odBounds);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetUpdateBox
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::GetUpdateBox(FW_CRect& updateBox) const
- {
- updateBox = GetRectGeometry();
-
- const FW_Fixed fxMargin = FW_IntToFixed(3);
-
- updateBox.left -= fxMargin;
- updateBox.top -= fxMargin;
- updateBox.right += fxMargin;
- updateBox.bottom += fxMargin;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetDragRect
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::GetDragRect(FW_CRect& dragRect) const
- {
- dragRect = GetRectGeometry();
- AdjustRectForPenSize(dragRect, GetPenSize());
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetResizeStyle
- //----------------------------------------------------------------------------------------
-
- FW_CStyle CBaseShape::GetResizeStyle() const
- {
- FW_CStyle resizeStyle(GetPenSize(), FW_kGrayPat);
- return resizeStyle;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::SubtractToWindowClip
- //----------------------------------------------------------------------------------------
- // ATTENTION: windowClip is in Window coordinates. tempShape is just a working shape. It is
- // allocated by CDrawFrame::ClipEmbeddedFacets so I don't have to allocate one everytime.
-
- void CBaseShape::SubtractToWindowClip(Environment *ev,
- CDrawFacetClipper* facetClipper,
- ODFacet* containingFacet,
- ODShape* windowClip,
- ODShape* tempShape)
- {
- FW_UNUSED(facetClipper);
-
- GetClipRegion(ev, tempShape);
- FW_CAcquiredODTransform aqWindowContentTransform = containingFacet->AcquireWindowContentTransform(ev, NULL);
- tempShape->Transform(ev, aqWindowContentTransform); // in window coordinate
- windowClip->Subtract(ev, tempShape);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::WhichHandle
- //----------------------------------------------------------------------------------------
-
- short CBaseShape::WhichHandle(FW_CGraphicContext& gc, const FW_CPoint& mouse) const
- {
- FW_CPoint penSize = gc.DeviceToLogical(4, 4);
- for (short i=1; i<=fNumberOfHandles; i++)
- {
- CalcHandle(i, CBaseShape::gWorkingHandle, penSize);
- if (CBaseShape::gWorkingHandle->HitTest(gc, mouse, FW_kFixed0))
- return i;
- }
-
- return 0;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::IsInLinkDestination
- //----------------------------------------------------------------------------------------
- FW_Boolean CBaseShape::IsInLinkDestination(Environment* ev)
- {
- return IsSubscribed();
- }
-